package com.azthink.chaper411.configuration;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

//测试类
public class TestMain {
    public static void main(String[] args) {
        // @Configuration注解的spring容器加载方式，用AnnotationConfigApplicationContext替换ClassPathXmlApplicationContext
        ApplicationContext context  = new AnnotationConfigApplicationContext(TestConfiguration.class);

        //传统对象的实例化
//        TestBean tb = new TestBean();
//        tb.sayHello();
        //从Spring容器获取TestBean对象
        TestBean tb = (TestBean)context.getBean("testBean");
        tb.sayHello();
        System.out.println(tb);

//        TestBean tb2 = (TestBean)context.getBean("testBean");
//        tb2.sayHello();
//        System.out.println(tb2);



    }



}
